﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BT_BieuThuc_Nhom13.Converter
{
    public abstract class MyConverter
    {
        static List<MyConverter> RegisteredConverters;
        protected String Name;
        protected List<OrderIndex> lstOrder;

        public virtual List<OrderIndex> GetListFormat()
        {
            return null;
        }

        public static MyConverter GetConverter(String Name)
        {
            if (RegisteredConverters == null)
            {
                InitialListConverter();
            }

            MyConverter Result = RegisteredConverters.Where(converter => converter.Name == Name).SingleOrDefault();
            return Result;

        }

        protected static void InitialListConverter()
        {
            RegisteredConverters = new List<MyConverter>();
            RegisteredConverters.Add(InfixConverter.GetInstance());
            RegisteredConverters.Add(PrefixConverter.GetInstance());
            RegisteredConverters.Add(SuffixConverter.GetInstance());
        }

    }
}
